package com.example.blog.pojo;

import com.example.blog.constant.Constant;
import lombok.Data;
import lombok.Setter;

@Data
@Setter
public class Result<T> {
    private int code;
    private String message;
    private T data;

    public void setCode(int code) {
        this.code = code;
    }

    public static <T> Result success(T data){
       Result<T> result= new Result<>();
       Constant resultCode=new Constant();
       result.setCode(resultCode.REUSLT_SUCESS);
       result.setMessage("");
       result.setData(data);
       return result;
    }

    public static<T> Result fail(String mesg){
        Result<T> result= new Result<>();
        Constant resultCode=new Constant();
        result.setCode(resultCode.REUSLT_FAIL);
        result.setMessage(mesg);
        return result;
    }
}
